<template>
  <div>
    <div class="myReleaset">
      <table border="1" width='100%' cellspacing="0" cellpadding="0" id="myRelesad"
             style="font-size:18px;text-align: center;">
        <tr height="40">
          <th width="445">投标信息</th>
          <th width="200">投标状态</th>
          <th width="230">投标保证金</th>
          <th width="230">开标时间</th>
          <th width="230">操作</th>
        </tr>
        <tr height="40" style="font-size:13px;" v-for="item in  items">
          <td>{{item.projectName}}</td>
          <td><span v-if="item.bidOrder.payStatus ==0 ">未支付</span><span v-else>已支付</span></td>
          <td>{{item.bidOrder.bidBond}}</td>
          <td>{{format(item.endDate,'yyyy-MM-dd')}}</td>
          <td>
            <el-button class="checkViewq" :name=item.bidOrder.tenderid type="button" @click="dialogVisibles($event)">查看</el-button>


          </td>
        </tr>
      </table>
       <el-dialog
              title="项目信息"
              :visible.sync="dialogVisible"
              size="tiny"
              :before-close="handleClose" id="classbb">
              <Toubiaoinformation :message2=parentMsgs v-if=dialogVisible></Toubiaoinformation>

            </el-dialog>
      <div class="pages_as">
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage3"
            :page-size="12"
            layout="prev, pager, next, jumper"
            :total="counts">
          </el-pagination>
        </div>

      </div>

    </div>
  </div>
</template>

<script>
  import Toubiaoinformation from '@/components/Toubiaoinformation'
  export default {
    data () {
      return {
        currentPage3: 1,
        counts: 10,
        dialogVisible: false,
        items:[],
        parentMsgs:'s',
        userId:''
      }
    },
    methods: {
      setCookie: function (cname, cvalue, exdays) {
        var d = new Date();
        d.setTime(d.getTime() + (exdays * 60 * 1000));
        var expires = "expires=" + d.toUTCString();
        console.info(cname + "=" + cvalue + "; " + expires);
        document.cookie = cname + "=" + cvalue + "; " + expires;
        console.info(document.cookie);
      },
      //获取cookie
      getCookie: function (cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
          var c = ca[i];
          while (c.charAt(0) == ' ') c = c.substring(1);
          if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
        }
        return "";
      },
      //清除cookie
      clearCookie: function () {
        this.setCookie("username", "", -1);

      },
      handleClose(done) {
        done();
      },
      handleSizeChange (val) {
        console.log(`每页 ${val} 条`)
        this.mytoub(10,val)
      },
      handleCurrentChange (val) {
        console.log(`当前页: ${val}`)
        this.mytoub(10,val)
      },
      mytoub(countt,pagee){
         let that=this
        $.ajax({
          type: "post",
          url: local+"/awm/userManage/getMyBid",
          data: {

            count:countt,
            page:pagee
          },
          dataType: "json",
          beforeSend:function (xhr) {
            xhr. withCredentials=true
          },
          success: function(data){
             if(data.code==202){
                that.$message.error('登录过期请重新登录');
               sessionStorage.clear()
               //清除cookie
               that.setCookie("login", "", -1);
                let t;
                clearTimeout(t)
                t = setTimeout(function (){
                 that.$router.push({path: '/Entry',query: {redirect:'/Myaddress'}})
                }, 3000);
              }else{
                 that.counts=data.resultData.count
                 that.items=data.resultData.Bid
              }


          },
          error:function(aa){
            console.log(aa)
          }
        });
      },
      format(time, format) {
        var t = new Date(time);
        var tf = function(i){return (i < 10 ? '0' : '') + i};
        return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a){
          switch(a){
            case 'yyyy':
              return tf(t.getFullYear());
              break;
            case 'MM':
              return tf(t.getMonth() + 1);
              break;
            case 'mm':
              return tf(t.getMinutes());
              break;
            case 'dd':
              return tf(t.getDate());
              break;
            case 'HH':
              return tf(t.getHours());
              break;
            case 'ss':
              return tf(t.getSeconds());
              break;
          }
        })
      },
      dialogVisibles(e){
        this.dialogVisible = true
        this.parentMsgs = $(e.currentTarget).attr('name')

      },

    },
    mounted: function () {
      this.userId = sessionStorage.getItem('userId')
      this.mytoub(10,1)
    },
    components: {
      Toubiaoinformation
    }
  }
</script>

<style scoped>
  .myReleaset {
    width: 100%;
    height: 498px;
    /*background: pink;*/
    position: relative;
  }

  .checkViewq {
    width: 58px;
    height: 20px;
    border: 1px solid #9d9d9d;
    font-size: 12px;
    border-radius: 5px;
    margin-right: 30px;
    padding:0;

  }

  .deleteListq {
    width: 58px;
    height: 20px;
    border: 1px solid #9d9d9d;
    font-size: 12px;
    border-radius: 5px;
    line-height: 20px;
    padding: 0;
    background: buttonface;;
  }

  .pages_as {
    width: 100%;
    height: 30px;
    position: absolute;
    bottom: -40px;
    left: 0;
  }
</style>
